package com.yunji.bid.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunji.bid.entity.TBid;
import com.yunji.bid.mapper.TBidMapper;
import com.yunji.bid.query.QueryBid;
import com.yunji.bid.service.TBidService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 宝贝投资
 * @since 2020-02-14
 */
@Service
public class TBidServiceImpl extends ServiceImpl<TBidMapper, TBid> implements TBidService {

    @Override
    public void selectPageBid(Page<TBid> pageParam, QueryBid queryBid) {
        QueryWrapper<TBid> queryWrapper=new QueryWrapper();
        queryWrapper.orderByAsc("borrow_state");
        if (queryBid==null){
            baseMapper.selectPage(pageParam,queryWrapper);
            return ;
        }
        if (queryBid.getBeginDate()!=null&&queryBid.getBeginDate()!=""){
            queryWrapper.between("bid_time",queryBid.getBeginDate(),queryBid.getEndDate());
        }
        if (!StringUtils.isEmpty(queryBid.getBorrowState())){
            queryWrapper.eq("borrow_state",queryBid.getBorrowState());
        }
        if (!StringUtils.isEmpty(queryBid.getUserId())){
            queryWrapper.eq("bid_user_id",queryBid.getUserId());
        }
        baseMapper.selectPage(pageParam,queryWrapper);
    }
}
